﻿#ifndef NETWORKDEBUGWIDGET_H
#define NETWORKDEBUGWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QButtonGroup>
#include <QComboBox>

#include "GlobalDef.h"
#include "MessDispath.h"

#include "ui_NetworkDebugWidget.h"

#include "TcpServerController.h"
#include "TcpClientController.h"
#include "UdpUnicastController.h"
#include "UdpBroadcastController.h"
#include "UdpMulticastController.h"

namespace Core {

	class NetworkDebugWidget : public QWidget
	{
		Q_OBJECT

	public:
		explicit NetworkDebugWidget(QWidget *parent = Q_NULLPTR);
		~NetworkDebugWidget();

	private Q_SLOTS:
		/**
		 * @brief	slotNetworkTypeCurrentlndexChanged
		 * @param	index
		 * @return 
		 */
		void slotNetworkTypeCurrentlndexChanged(int index);

		/**
		* @brief	slotNetworkControlBtnClicked 串口控制按钮
		* @return
		*/
		void slotNetworkControlBtnClicked();

		/**
		* @brief	slotSendMsgTypeButtonClicked  设置发送的信息类型
		* @param	id
		* @return
		*/
		void slotSendMsgTypeButtonClicked(int id);

		/**
		* @brief	slotRecvMsgTypeButtonClicked 设置接收的信息类型
		* @param	id
		* @return
		*/
		void slotRecvMsgTypeButtonClicked(int id);

		/**
		* @brief	slotRepeatSendCheckBoxStateChanged 设置是否重复发送
		* @param	state 状态
		* @return
		*/
		void slotRepeatSendCheckBoxStateChanged(int state);

		/**
		* @brief	slotSerialPortSendMsgBtnClicked 发送串口信息
		* @return
		*/
		void slotNetworkSendMsgBtnClicked();

		/**
		* @brief	slotSerialPortMsgInfo 串口的信息
		* @param	strMsg 信息
		* @return
		*/
		void slotNetworkMsgInfo(int iMsgType, QString strMsg);


	private:
		/**
		 * @brief	initUI
		 * @return 
		 */
		void initUI();

	private:
		Ui::NetworkDebugWidget ui;
		int m_iNetworkType;
		TcpServerController * m_pTcpServerController;
		TcpClientController *m_pTcpClientController;
		UdpUnicastController *m_pUdpUnicastController;
		UdpBroadcastController *m_pUdpBroadcastController;
		UdpMulticastController *m_pUdpMulticastController;


		QButtonGroup * m_pSendButtonGroup;							// 发送配置
		QButtonGroup * m_pRecvButtonGroup;							// 接收配置

		QStringList m_strSendMsgList;								// 发送的消息队列
		QTimer * m_pTimerRepeatSend;								// 刷新串口列表

	};

}// namespace Core 

#endif // NETWORKDEBUGWIDGET_H